package com.caoheng.oms.vo;

import com.caoheng.entity.MerchantInfo;
import lombok.Data;

@Data
public class MerchantInfoBody {

    private String name;

    private String type;

    private String requestKey;

    private String responseKey;

    private byte state;

    public MerchantInfo convert(){
        return commonConstructor(null);
    }

    public MerchantInfo convert(MerchantInfo merchantInfo){
        return commonConstructor(merchantInfo);
    }

    private MerchantInfo commonConstructor(MerchantInfo merchantInfo){
        MerchantInfo.Builder builder = merchantInfo != null ? new MerchantInfo.Builder(merchantInfo) : new MerchantInfo.Builder();
        return builder
                .generateId()
                .name(name)
                .requestKey(requestKey)
                .responseKey(responseKey)
                .type(type)
                .state(state).build();
    }
}
